<template>
  <div>
    <p>计数器的值：{{ counter }}</p>
  </div>
</template>

<script setup>
import { ref,defineExpose } from "vue";

const counter = ref(1);

/* 定义了两个API */
const increase = (n) => {
  counter.value += n;
};

const multiply = (n) => {
  counter.value *= n;
};

// 向父组件暴露自己的API 供其调用
defineExpose({
  increase,
  multiply,
});
</script>
